<?php
 //August,02,2012: tunv rewrite code module link tabs
class linktabs{
	function form($object, $config) {
		if (!defined('SYS_FORMS')) require_once(BASE.'subsystems/forms.php');
		exponent_forms_initialize();

		$form = new form();
		if (!isset($object->id)) {
			$object->name = '';
			$object->url = 'http://';
			$object->description = '';
			$object->opennew = 0;
            $object->file_id=0;
			$object->post_date=0;
            $object->special_link='';
            $object->special_link_title='';
            $object->body2='';
		} else {
			$form->meta('id',$object->id);
		}
        //$config->remove_body_html=1;
        if ($config->name_multiline == 1)
        {
            $form->register('name','Name',new texteditorcontrol($object->name,5,77));
        }
        else
        {
            $form->register('name','Name',new textcontrol($object->name));
        }
		$form->register('url','URL',new textcontrol($object->url));
        $form->register('special_link','Special Link',new textcontrol($object->special_link));
        $form->register('special_link_title','Special Link Title',new textcontrol($object->special_link_title));
		$form->register('file_id','Image', new ajax_select_file("file_id",0,$object->file_id,true));
		$form->register('opennew','Open in New Window',new checkboxcontrol($object->opennew,true));
       
       if($config->name_multiline==1)
        {
            $form->register('body2','Short Description',new texteditorcontrol($object->body2, 3, 75)); 
        }
        
         if ($config->remove_body_html==1){
            $form->register('description','Description',new  texteditorcontrol($object->description,10,40));
        }
        else
        {
            $form->register('description','Description',new htmleditorcontrol($object->description));   
        }
        
        if (!isset($object->id))
            $form->register('post_date',"Post date",new yuidatetimecontrol($object->post_date,"", true, true, false, false));
            
		$form->register('submit','',new buttongroupcontrol('Save','','Cancel'));
		return $form;
	}
	function update($values,$object) {
		$object->text = $values['text'];
		$object->title = $values['title'];
        global $db;
        $type_news = $db->selectObject('linktabsmodule_link',"id={$values['type_news']}");
        $object->type_news = $type_news->type_news;
        $object->summary = $values['summary'];
		$object->file_id = $values['file_id'];
        if (!isset($object->id))
        {
            $object->post_date = yuidatetimecontrol::parseData('post_date',$values);
        }
        if ($object->post_date == 0)
            $object->post_date = time();
		return $object;
	}
    function form_text_post($object, $config) {
        if (!defined('SYS_FORMS')) require_once(BASE.'subsystems/forms.php');
        exponent_forms_initialize();

        $form = new form();
        if (!isset($object->id)) {
            $object->text = '';
            $object->title = '';
            $object->type_news = 0;
            $object->summary = '';
            $object->file_id=0;
            $object->post_date=0;
        } else {
            $form->meta('id',$object->id);
        }
        global $db;
        $type_news = $db->selectDropdown('linktabsmodule_link',name,'','');
        $form->register('title','Title',new textcontrol($object->title));
        $form->register('type_news','Type News',new dropdowncontrol($object->type_news,$type_news,false));
        $form->register('summary','Summary',new texteditorcontrol($object->summary));
        $form->register('text','Text',new htmleditorcontrol($object->text));
        $form->register('file_id','Image', new ajax_select_file("file_id",0,$object->file_id,true));
        if (!isset($object->id))
            $form->register('post_date',"Post date",new yuidatetimecontrol($object->post_date,"", true, true, false, false));
            
        $form->register('submit','',new buttongroupcontrol('Save','','Cancel'));
        return $form;
    }
}

?>